package com.zxx.casserver.base.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户关系类型
 *
 * @author zhoukai
 * @date 2022/7/14 11:25
 */
public enum UserRelationTypeEnum {
    ROLE("role", 1),
    SYSTEM("system", 2),
    ;

    private String name;
    private Integer index;

    UserRelationTypeEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static List<String> getAllName() {
        List<String> names = new ArrayList<>();
        for (UserRelationTypeEnum c : UserRelationTypeEnum.values()) {
            names.add(c.getName());
        }
        return names;
    }

    public static List<Integer> getAllIndex() {
        List<Integer> indexs = new ArrayList<>();
        for (UserRelationTypeEnum c : UserRelationTypeEnum.values()) {
            indexs.add(c.getIndex());
        }
        return indexs;
    }

    public static String getName(int index) {
        for (UserRelationTypeEnum c : UserRelationTypeEnum.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }
}
